package com.example.demo;

import com.alibaba.dubbo.spring.boot.annotation.EnableDubboConfiguration;
import com.example.dubbo.service.SomeService;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@SpringBootApplication
@MapperScan(basePackages = "com.example.demo.mapper") // 扫描
@EnableTransactionManagement // 开启事务支持(可选项，但@Transactional 必须添加)
@EnableDubboConfiguration
public class DemoApplication2 {

  public static void main(String[] args) {

    // 关闭Banner
    SpringApplication springApplication = new SpringApplication(DemoApplication3.class);
    springApplication.setBannerMode(Banner.Mode.OFF);

    /**
     * SpringBoot 程序启动后，返回值是 ConfigurableApplicationContext，它也是一个 Spring 容器对象
     * 它其它相当于原来 Spring 中启动容器 ClassPathXmlApplicationContext context = new
     * ClassPathXmlApplicationContext("");
     */

    ConfigurableApplicationContext context = springApplication.run(args);
    SomeService service = (SomeService) context.getBean("someServiceImpl");
    System.out.println(service.hello());
  }

}
